<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>创业者服务首页</title>
		<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css"/>
		<link rel="stylesheet" href="../css/leftSidebar.css">
	</head>
	<style type="text/css">
        html,body{height: 100%;padding-bottom: 50px;}
		.col-xs-12.nav_right{padding: 0;height: 100px;padding-right: 0;margin-right: 0;min-width: 1100px;height: 100px;padding-right: 0;margin-right: 0;padding-left: 160px;}
		#myTab a{color: #7c7c7c; ;font-size: 15px;}
		#myTab>li.active>a{color: #3f4142; background-color: #fff;}
		.navbar-form{margin-top: 0;}
		.tab_creat .active{color:#6bc50d;}
		.table>tbody>tr.active>td, .table>tbody>tr.active>th, .table>tbody>tr>td.active, .table>tbody>tr>th.active, .table>tfoot>tr.active>td, .table>tfoot>tr.active>th, .table>tfoot>tr>td.active, .table>tfoot>tr>th.active, .table>thead>tr.active>td, .table>thead>tr.active>th, .table>thead>tr>td.active, .table>thead>tr>th.active{background-color: #fff;}
		.table>tfoot>tr.active>td{background-color: #fff;}
		.table>tbody>tr>td{border-top:0;}
		.table{margin-bottom: 0;}
		div.tab_creat.row{background-color: #fff;}
		.tab_font{padding: 10px 0;}
		.tab_font div,.tab_font td{font-size: 14px;color: #919191;}
		.gongsi_list div.col-xs-2,.gongsi_list div.col-xs-1{text-align: center;padding: 20px 0;}
		.gongsi_list.row{background-color: #fff;margin-top: 20px;}
		.gongsi_list dd div.col-xs-2{font-size: 14px;color: #4f5051;}
		.row{margin: 0;}
		.sub_logo{position: relative;display: inline-block;padding-left: 0;}
		.sub_logo input{opacity: 0;position: absolute;left: 0;right: 0;bottom: 0;top: 0;}
		.zhube_head{border-bottom: 1px solid #ddd;}
		.zhube_head h3{padding: 5px 0;, ;color: #222c38;font-size: 16px;border-bottom: 4px solid #5a626d;}
			
		#form_test label{font-size: 14px; ;color: #515151;font-weight: normal;}
		#form_test  .media-middle{font-size: 14px;color: #acacac;}
		.form_tip{font-size: 12px;color: #acacac; ;}
		.btn-default{border-color: #d5272d ;color: #d5272d ;}
		.btn-default.disabled{background-color: #ccc;color: #fff;border-color:#ccc;}
		.btn-default.disabled.focus, .btn-default.disabled:focus, .btn-default.disabled:hover, .btn-default[disabled].focus, .btn-default[disabled]:focus, .btn-default[disabled]:hover, fieldset[disabled] .btn-default.focus, fieldset[disabled] .btn-default:focus, fieldset[disabled] .btn-default:hover{background-color: #ccc;color: #fff;}

		#daoshi_list>dd:hover,#daoshi_list>dd.active{background-color: #ffe6e7;cursor: pointer}
	</style>
	<body style="background-color: #f2f2f2;">
		<div class="row warp" style="height: 100%;">
			<div class="nav_right_head">
				<a href="../index.html"><img src="../img/roleIndexBg.jpg" onerror="onErrorHandle(this)"/></a>
			</div>
			<!--左侧导航-->
			<div class="col-xs-2 nav_left">
				<div class="creatNav">创业者服务</div>
				<div class="creatLoginStatus"><img src="../img/avtar.png"><a>您好，创业者</a></div>
				<div class="list-group" style="padding: 0;">
					<a href="cyzfw_index.html" class="list-group-item "><i class="glyphicon glyphicon-home"></i> 首页</a>
					<a href="cyzfw_zuche.html" class="list-group-item"><i class="glyphicon glyphicon-plus-sign"></i> 注册项目</a>
					<a href="cyzfw_myProgress.html" class="list-group-item active"><i class="glyphicon glyphicon-folder-open"></i> 我的项目</a>
					<a href="cyzfw_mynews.html" class="list-group-item"><i class="glyphicon glyphicon-book"></i> 我的消息</a>
					<div class="list-group listAttention">
						<div class="list-group-item" > <span class="caret"></span> 我的关注</div>
						<a href="cyzfw_gz_touziren.html" class="list-group-item"><i class="glyphicon glyphicon-usd"></i> 投资人/机构</a>
						<a href="cyzfw_gz_daoshi.html" class="list-group-item"><i class="glyphicon glyphicon-user"></i> 导师</a>
						<a href="cyzfw_gz_xiangmu.html" class="list-group-item"><i class="glyphicon glyphicon-lock"></i> 项目</a>
					</div>

				</div>
				<div class="backBtn"> <a href="../index.html"><img src="../img/backIndex.png"></a></div>
			</div>
			
			<div class="col-xs-12 nav_right" style="">

	
				<div class="row" style="margin-top: 10px;">
					<div class="col-xs-12" >
					<div class="panel panel-default">
					  <div class="panel-heading">
					    <h3 class="panel-title">我的项目</h3>
					  </div>
					  <div class="panel-body" style="padding: 0;">
					    <div class="row gongsi_list">
							<dl style="background-color: #fff;">
										<dt>
											<div class="row">
												<div class="col-xs-2">双创项目</div>
												<div class="col-xs-2">项目状态</div>
												<div class="col-xs-2">项目编号</div>
												<div class="col-xs-1">创业领域</div>
												<div class="col-xs-2">项目注册时间</div>
												<div class="col-xs-1">导师</div>
												<div class="col-xs-1">投资者/机构</div>
												<div class="col-xs-1">操作</div>
											</div>
										</dt>
										<div id="myPbList">
											<!--<dd>-->
												<!--<div class="row">-->
													<!--<div class="col-xs-2" style="padding-top: 10px;">-->
														<!--<div class="media">-->
															<!--<div class="media-left media-middle" style="padding: 0px 15px;">-->
																<!--<img src="../img/13.jpg" style="width: 40px;height: 40px;"/>-->
															<!--</div>-->
															<!--<div class="media-body text-left">-->
																<!--<span style="display: inline-block;margin-top: 10px;"><a href="cyzfw_myProgress_xq.html">小橙科技</a></span>-->
															<!--</div>-->
														<!--</div>-->
													<!--</div>-->
													<!--<div class="col-xs-2">审核通过</div>-->
													<!--<div class="col-xs-2">201703024</div>-->
													<!--<div class="col-xs-1">生活消费</div>-->
													<!--<div class="col-xs-2">2015-06-11</div>-->
													<!--<div class="col-xs-1">陈军<br>陈希军</div>-->
													<!--<div class="col-xs-1">双创平台</div>-->
													<!--<div class="col-xs-1"><a href="cyzfw_modify.html" >修改</a></div>-->
												<!--</div>-->
											<!--</dd>-->
										</div>


							
							</dl>

						</div>
					  </div>
					</div>
					</div>


				</div>
					
		</div>
		</div>


		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
			<div class="modal-dialog" role="document">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="myModalLabel">请选择导师<small>（多选位联合辅导，单选拒绝其他导师）</small></h4>
					</div>
					<div class="modal-body">

						<div class="row gongsi_list">
							<dl style="background-color: #fff;">
								<dt>
								<div class="row">
									<div class="col-xs-4">导师</div>
									<div class="col-xs-4">地区</div>
									<div class="col-xs-4">研究领域</div>
								</div>
								</dt>
								<!--<dd>-->
								<!--<div class="row">-->
								<!--<div class="col-xs-4" style="padding-top: 10px;">-->
								<!--<div class="media">-->
								<!--<div class="media-left media-middle" style="padding: 0px 15px;">-->
								<!--<img src="../img/11.jpg" style="width: 40px;height: 40px;"/>-->
								<!--</div>-->
								<!--<div class="media-body text-left">-->
								<!--<span style="display: inline-block;margin-top: 10px;"><a href="cyzfw_myProgress_xq.html">无人机</a></span>-->
								<!--</div>-->
								<!--</div>-->
								<!--</div>-->
								<!--<div class="col-xs-2">201703024</div>-->
								<!--<div class="col-xs-2">生活消费</div>-->
								<!--<div class="col-xs-1">陈希东</div>-->
								<!--<div class="col-xs-2">无</div>-->
								<!--<div class="col-xs-1">关注</div>-->
								<!--</div>-->
								<!--</dd>-->
								<div>
									<div id="daoshi_list"></div>
									<ul class="pagination pull-right" id="pageTutor">

									</ul>
								</div>

							</dl>

						</div>


					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default confirmBtn">确认</button>
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script src="../js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../js/bootstrap.min.js" ></script>
	<script type="text/javascript" src="../js/bootstrap-paginator.min.js"></script>
	<script type="text/javascript" src="../js/public.js"></script>
	<script type="text/javascript">


        var person = JSON.parse(sessionStorage.getItem("person"));
        if (person==''||person==null) {
			alert('请先登录')
			 window.location.href='denglu.html';
        } else{
            var userId = person.userid;
        }

		//我的项目列表
	$.ajax({
                type: "get",
                url:"http://114.112.96.184:18080/startup/myPb",
				data:{'userId':userId},
                error: function(request) {
                    console.log("Connection error");
                },
                success: function(data) {
                    console.log(data)
                   var obj = data.result.content;
                   var htmls='';

                   for (var i = 0; i < obj.length;i++) {
                       var pbName = '';
                       var status = '';
                       var no = obj[i].no.substring(0,10)+'...';

                       console.log(no)
                       var createTime =obj[i].createTime.substring(0,10)
                       pbName=obj[i].pbName;
                       if (pbName.length>4){
                           pbName=pbName.substring(0,4) + '...'
                       }
                       status= obj[i].status;
                       if (status==0){
                           status='正在审核'
                       }else if (status>=10){
                           status='审核通过'
                       }else {
                           status="审核未通过"
                       }
					   var tutorName = '';
					   if(obj[i].tutorNames){
						   tutorName=obj[i].tutorNames
					   }else {
						   tutorName='暂无导师'
					   }
					   var invests = '';
					   if(obj[i].invests){
						   invests=obj[i].invests
					   }else {
						   invests='暂无'
					   }
                 	htmls+=  '<dd><div class="row"><div class="col-xs-2" style="padding-top: 10px;"><div class="media"><div class="media-left media-middle" style="padding: 0px 15px;"><img src="'+ obj[i].logo +'" onerror="onErrorHandle(this)" style="width: 40px;height: 40px;"/></div>'+
													 '<div class="media-body text-left">'+
													      '<span style="display: inline-block;margin-top: 10px;"><a href="cyzfw_myProgress_xq.html?'+ obj[i].id +'" title="'+obj[i].pbName+'">'+ pbName+'</a></span>'+
													  '</div>'+
													'</div>'+
												'</div>'+
												'<div class="col-xs-2">'+status+'</div>'+
												'<div class="col-xs-2" title="'+obj[i].no+'">'+no +'</div>'+
												 '<div class="col-xs-1">'+ obj[i].field+'</div>'+
												'<div class="col-xs-2">'+createTime+'</div>'+
												 '<div class="col-xs-1 tutorList" data-toggle="modal"  pbId="'+obj[i].id+'">'+ tutorName+'</div>'+
												 '<div class="col-xs-1">'+invests+'</div>'+
												 '<div class="col-xs-1" modify="'+obj[i].id+'"><a href="cyzfw_modify.html?'+obj[i].id+'">修改</a></div>'+
											 '</div>'+
										'</dd>'
                   }
                   $('#myPbList').html(htmls);
                }
            });

		function onErrorHandle(obj){
			obj.src="../img/defaultAvatar.png";
		}






		$(document).on('click','.tutorList',function () {
			$('#myModal').modal('show')
			var id = $(this).attr('pbId');
//			if ($(this).text()=='新的申请'){
				getTutorList({'userId':userId},1,10);
//			}
			function getTutorList(objs,page,pageSize) {
				objs.index=page;
				objs.size=pageSize;
				$.ajax({
					type: "get",
					data:objs,
					url:"http://114.112.96.184:18080/startup/myPb/"+ id +"/tutor",
					async: false,
					error: function(request) {
						console.log("Connection error");
					},
					success: function(data) {
						console.log(data);
						var pages=Math.ceil(data.result.totalElements/10);
						if(pages<=1){
							$("#pageTutor").hide();
						}else{
							$("#pageTutor").show();
						}
						var options= {
							bootstrapMajorVersion: 3,
							currentPage: page,    //当前页数
							numberOfPages: 10,
							totalPages: pages,    //所有数据可以显示的页数
							tooltipTitles: function () {
							},
							itemTexts: function (type, page, current) {
								switch (type) {
									case "prev":
										return "←上一页";
									case "next":
										return "下一页→";
									case "page":
										return page;
								}
							},
							shouldShowPage: function (type, page, current) {
								switch (type) {
									case "first":
									case "last":
										return false;
									default:
										return true;
								}
							},
							onPageClicked: function (event, originalEvent, type, page) {
								objs.index=page;
								$.ajax({
									type: "get",
									data: {'userId': userId, 'index': page, 'size': pageSize},
									url: "http://114.112.96.184:18080/startup/myPb/"+ id +"/tuto",
									async: false,
									error: function (request) {
										console.log("Connection error");
									},
									success: function (data) {
										var obj = data.result.content;
										var htmls='';
										for (var i = 0; i < obj.length;i++) {
											var attention='';
											var createTime='';
											if (obj[i].attention==true) {
												attention='取消关注'
											} else{
												attention='关注'
											}
											if(obj[i].userId==userId){
												attention='我';
											}
											htmls+= '<dd>'+
													'<div class="row">'+
													'<div class="col-xs-2" style="padding-top:3px ;"><img src="'+obj[i].avatar +'" onerror="onErrorHandle(this)" style="width: 40px;height: 40px;"/> <a href="cyzfw_ckds.html?'+ obj[i].id +'">'+ obj[i].realName+'</a></div>'+
													'<div class="col-xs-2">'+obj[i].case+'</div>'+
													'<div class="col-xs-2">'+ obj[i].education+'</div>'+
													'<div class="col-xs-2">'+ obj[i].area+'</div>'+
													'<div class="col-xs-2">'+ obj[i].researchField+'</div>'+
													'</div>'+
													'</dd>'
										}
										$('#daoshi_list').html(htmls);
									}
								})


							}
						}

						if(data.result.totalElements>0){
							$("#pageTutor").bootstrapPaginator(options);
						}

						var obj = data.result.content;
						var htmls='';
						for (var i = 0; i < obj.length;i++) {
							var attention='';
							var createTime='';
							if (obj[i].attention==true) {
								attention='取消关注'
							} else{
								attention='关注'
							}
							htmls+= '<dd  tutorId="'+obj[i].id+'">'+
									'<div class="row">'+
									'<div class="col-xs-4" style="padding-top:3px ;"><img src="'+obj[i].avatar +'" onerror="onErrorHandle(this)" style="width: 40px;height: 40px;"/> <a href="cyzfw_ckds.html?'+ obj[i].id +'">'+ obj[i].realName+'</a></div>'+
									'<div class="col-xs-4">'+ obj[i].area+'</div>'+
									'<div class="col-xs-4">'+ obj[i].researchField+'</div>'+
									'</div>'+
									'</dd>'
						}
						$('#daoshi_list').html(htmls).on('click','dd',function () {
//							var tutorId=$(this).attr('tutorId');
							$(this).toggleClass('active');



						});

						$('.confirmBtn').on('click',function () {
							var tutorIds = getChooseId('#daoshi_list');
							$.ajax({
								type: "post",
								data: {'userId': userId,'type':1},
								url: "http://114.112.96.184:18080/startup/myPb/"+id+"/tutor/"+tutorIds,
								async: true,
								error: function (request) {
									console.log("Connection error");
								},
								success: function (data) {
									console.log(data)
									$('#myModal').modal('hide')
								}

							});


						})

						function getChooseId (select){
							var obj =	$(select).find('dd').filter('.active');
							var rongzi_value = "";
							for (var i = 0; i < obj.length;i++) {
								rongzi_value+= obj[i].getAttribute('tutorId')+ ','
							}
							rongzi_value=rongzi_value.substring(0,rongzi_value.length-1)
							return rongzi_value;
						}
					}
				});
			}
		})


	</script>
</html>
